﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace NotAClue.Web.DynamicData
{
    public static class MetadataSitMapProviderExtensionMethods
    {

        /// <summary>
        /// helper method to check for roles in this attribute
        /// the comparison is case insensitive
        /// </summary>
        /// <param name="roles"></param>
        /// <returns></returns>
        public static Boolean HasAnyRole(this String[] userRoles, IList roles)
        {
            // call extension method to convert array to lower case for compare
            var lowerCaseUserRoles = userRoles.AllToLower();
            foreach (String role in roles)
            {
                if (lowerCaseUserRoles.Contains(role.ToLower()))
                    return true;
            }
            return false;
        }
    }
}
